import jagex.client.*;
import jagex.DataOperations;
import java.io.IOException;

public class Terrain {

	public Terrain(Camera arg0, GameImage arg1) {
		udb = true;
		vdb = false;
		ydb = 750;
		groundTextureArray = new int[256];
		heb = new byte[4][2304];
		ieb = new byte[4][2304];
		jeb = new byte[4][2304];
		keb = new byte[4][2304];
		leb = new byte[4][2304];
		meb = new byte[4][2304];
		neb = new byte[4][2304];
		oeb = new int[4][2304];
		peb = 96;
		qeb = 96;
		reb = new int[peb * qeb * 2];
		seb = new int[peb * qeb * 2];
		tmpTiles = new int[peb][qeb];
		walkableValue = new int[peb][qeb];
		veb = new int[peb][qeb];
		playerIsAlive = false;
		xeb = new Model[64];
		yeb = new Model[4][64];
		zeb = new Model[4][64];
		xdb = arg0;
		gameImage = arg1;
		for (int k = 0; k < 64; k++) {
			groundTextureArray[k] = Camera.zh(255 - k * 4,
					255 - (int) ((double) k * 1.75D), 255 - k * 4);
		}

		for (int l = 0; l < 64; l++) {
			groundTextureArray[l + 64] = Camera.zh(l * 3, 144, 0);
		}

		for (int i1 = 0; i1 < 64; i1++) {
			groundTextureArray[i1 + 128] = Camera.zh(
					192 - (int) ((double) i1 * 1.5D),
					144 - (int) ((double) i1 * 1.5D), 0);
		}

		for (int j1 = 0; j1 < 64; j1++) {
			groundTextureArray[j1 + 192] = Camera.zh(
					96 - (int) ((double) j1 * 1.5D),
					48 + (int) ((double) j1 * 1.5D), 0);
		}

	}

	public int getStepCount(int walkSectionX, int walkSextionY, int x1, int y1, int x2, int y2, int walkSectionXArray[], int walkSectionYArray[], boolean arg8) {
		for (int k = 0; k < peb; k++) {
			for (int l = 0; l < qeb; l++) {
				tmpTiles[k][l] = 0;
			}
		}

		int i1 = 0;
		int j1 = 0;
		int k1 = walkSectionX;
		int l1 = walkSextionY;
		tmpTiles[walkSectionX][walkSextionY] = 99;
		walkSectionXArray[i1] = walkSectionX;
		walkSectionYArray[i1++] = walkSextionY;
		int i2 = walkSectionXArray.length;
		boolean flag = false;
		while (j1 != i1) {
			k1 = walkSectionXArray[j1];
			l1 = walkSectionYArray[j1];
			j1 = (j1 + 1) % i2;
			if (k1 >= x1 && k1 <= x2 && l1 >= y1 && l1 <= y2) {
				flag = true;
				break;
			}
			if (arg8) {
				if (k1 > 0 && k1 - 1 >= x1 && k1 - 1 <= x2 && l1 >= y1
						&& l1 <= y2 && (walkableValue[k1 - 1][l1] & 8) == 0) {
					flag = true;
					break;
				}
				if (k1 < peb - 1 && k1 + 1 >= x1 && k1 + 1 <= x2
						&& l1 >= y1 && l1 <= y2
						&& (walkableValue[k1 + 1][l1] & 2) == 0) {
					flag = true;
					break;
				}
				if (l1 > 0 && k1 >= x1 && k1 <= x2 && l1 - 1 >= y1
						&& l1 - 1 <= y2
						&& (walkableValue[k1][l1 - 1] & 4) == 0) {
					flag = true;
					break;
				}
				if (l1 < qeb - 1 && k1 >= x1 && k1 <= x2 && l1 + 1 >= y1
						&& l1 + 1 <= y2
						&& (walkableValue[k1][l1 + 1] & 1) == 0) {
					flag = true;
					break;
				}
			}
			if (k1 > 0 && tmpTiles[k1 - 1][l1] == 0
					&& (walkableValue[k1 - 1][l1] & 0x78) == 0) {
				walkSectionXArray[i1] = k1 - 1;
				walkSectionYArray[i1] = l1;
				i1 = (i1 + 1) % i2;
				tmpTiles[k1 - 1][l1] = 2;
			}
			if (k1 < peb - 1 && tmpTiles[k1 + 1][l1] == 0
					&& (walkableValue[k1 + 1][l1] & 0x72) == 0) {
				walkSectionXArray[i1] = k1 + 1;
				walkSectionYArray[i1] = l1;
				i1 = (i1 + 1) % i2;
				tmpTiles[k1 + 1][l1] = 8;
			}
			if (l1 > 0 && tmpTiles[k1][l1 - 1] == 0
					&& (walkableValue[k1][l1 - 1] & 0x74) == 0) {
				walkSectionXArray[i1] = k1;
				walkSectionYArray[i1] = l1 - 1;
				i1 = (i1 + 1) % i2;
				tmpTiles[k1][l1 - 1] = 1;
			}
			if (l1 < qeb - 1 && tmpTiles[k1][l1 + 1] == 0
					&& (walkableValue[k1][l1 + 1] & 0x71) == 0) {
				walkSectionXArray[i1] = k1;
				walkSectionYArray[i1] = l1 + 1;
				i1 = (i1 + 1) % i2;
				tmpTiles[k1][l1 + 1] = 4;
			}
			if (k1 > 0 && l1 > 0 && (walkableValue[k1][l1 - 1] & 0x74) == 0
					&& (walkableValue[k1 - 1][l1] & 0x78) == 0
					&& (walkableValue[k1 - 1][l1 - 1] & 0x7c) == 0
					&& tmpTiles[k1 - 1][l1 - 1] == 0) {
				walkSectionXArray[i1] = k1 - 1;
				walkSectionYArray[i1] = l1 - 1;
				i1 = (i1 + 1) % i2;
				tmpTiles[k1 - 1][l1 - 1] = 3;
			}
			if (k1 < peb - 1 && l1 > 0
					&& (walkableValue[k1][l1 - 1] & 0x74) == 0
					&& (walkableValue[k1 + 1][l1] & 0x72) == 0
					&& (walkableValue[k1 + 1][l1 - 1] & 0x76) == 0
					&& tmpTiles[k1 + 1][l1 - 1] == 0) {
				walkSectionXArray[i1] = k1 + 1;
				walkSectionYArray[i1] = l1 - 1;
				i1 = (i1 + 1) % i2;
				tmpTiles[k1 + 1][l1 - 1] = 9;
			}
			if (k1 > 0 && l1 < qeb - 1
					&& (walkableValue[k1][l1 + 1] & 0x71) == 0
					&& (walkableValue[k1 - 1][l1] & 0x78) == 0
					&& (walkableValue[k1 - 1][l1 + 1] & 0x79) == 0
					&& tmpTiles[k1 - 1][l1 + 1] == 0) {
				walkSectionXArray[i1] = k1 - 1;
				walkSectionYArray[i1] = l1 + 1;
				i1 = (i1 + 1) % i2;
				tmpTiles[k1 - 1][l1 + 1] = 6;
			}
			if (k1 < peb - 1 && l1 < qeb - 1
					&& (walkableValue[k1][l1 + 1] & 0x71) == 0
					&& (walkableValue[k1 + 1][l1] & 0x72) == 0
					&& (walkableValue[k1 + 1][l1 + 1] & 0x73) == 0
					&& tmpTiles[k1 + 1][l1 + 1] == 0) {
				walkSectionXArray[i1] = k1 + 1;
				walkSectionYArray[i1] = l1 + 1;
				i1 = (i1 + 1) % i2;
				tmpTiles[k1 + 1][l1 + 1] = 12;
			}
		}
		if (!flag) {
			return -1;
		}
		j1 = 0;
		walkSectionXArray[j1] = k1;
		walkSectionYArray[j1++] = l1;
		int k2;
		for (int j2 = k2 = tmpTiles[k1][l1]; k1 != walkSectionX || l1 != walkSextionY; j2 = tmpTiles[k1][l1]) {
			if (j2 != k2) {
				k2 = j2;
				walkSectionXArray[j1] = k1;
				walkSectionYArray[j1++] = l1;
			}
			if ((j2 & 2) != 0) {
				k1++;
			} else if ((j2 & 8) != 0) {
				k1--;
			}
			if ((j2 & 1) != 0) {
				l1++;
			} else if ((j2 & 4) != 0) {
				l1--;
			}
		}

		return j1;
	}

	public void ao(int arg0, int arg1, int arg2) {
		walkableValue[arg0][arg1] |= arg2;
	}

	public void addMinusWalkable(int arg0, int arg1, int arg2) {
		walkableValue[arg0][arg1] &= 65535 - arg2;
	}

	public void bo(int arg0, int arg1, int arg2, int arg3) {
		if (arg0 < 0 || arg1 < 0 || arg0 >= peb - 1 || arg1 >= qeb - 1) {
			return;
		}
		if (Cache.tib[arg3] == 1) {
			if (arg2 == 0) {
				walkableValue[arg0][arg1] |= 1;
				if (arg1 > 0) {
					ao(arg0, arg1 - 1, 4);
				}
			} else if (arg2 == 1) {
				walkableValue[arg0][arg1] |= 2;
				if (arg0 > 0) {
					ao(arg0 - 1, arg1, 8);
				}
			} else if (arg2 == 2) {
				walkableValue[arg0][arg1] |= 0x10;
			} else if (arg2 == 3) {
				walkableValue[arg0][arg1] |= 0x20;
			}
			in(arg0, arg1, 1, 1);
		}
	}

	public void updateDoor(int arg0, int arg1, int arg2, int arg3) {
		if (arg0 < 0 || arg1 < 0 || arg0 >= peb - 1 || arg1 >= qeb - 1) {
			return;
		}
		if (Cache.tib[arg3] == 1) {
			if (arg2 == 0) {
				walkableValue[arg0][arg1] &= 0xfffe;
				if (arg1 > 0) {
					addMinusWalkable(arg0, arg1 - 1, 4);
				}
			} else if (arg2 == 1) {
				walkableValue[arg0][arg1] &= 0xfffd;
				if (arg0 > 0) {
					addMinusWalkable(arg0 - 1, arg1, 8);
				}
			} else if (arg2 == 2) {
				walkableValue[arg0][arg1] &= 0xffef;
			} else if (arg2 == 3) {
				walkableValue[arg0][arg1] &= 0xffdf;
			}
			in(arg0, arg1, 1, 1);
		}
	}

	public void pn(int arg0, int arg1, int arg2) {
		if (arg0 < 0 || arg1 < 0 || arg0 >= peb - 1 || arg1 >= qeb - 1) {
			return;
		}
		if (Cache.iib[arg2] == 1 || Cache.iib[arg2] == 2) {
			int k = dn(arg0, arg1);
			int l;
			int i1;
			if (k == 0 || k == 4) {
				l = Cache.gib[arg2];
				i1 = Cache.hib[arg2];
			} else {
				i1 = Cache.gib[arg2];
				l = Cache.hib[arg2];
			}
			for (int j1 = arg0; j1 < arg0 + l; j1++) {
				for (int k1 = arg1; k1 < arg1 + i1; k1++) {
					if (Cache.iib[arg2] == 1) {
						walkableValue[j1][k1] |= 0x40;
					} else if (k == 0) {
						walkableValue[j1][k1] |= 2;
						if (j1 > 0) {
							ao(j1 - 1, k1, 8);
						}
					} else if (k == 2) {
						walkableValue[j1][k1] |= 4;
						if (k1 < qeb - 1) {
							ao(j1, k1 + 1, 1);
						}
					} else if (k == 4) {
						walkableValue[j1][k1] |= 8;
						if (j1 < peb - 1) {
							ao(j1 + 1, k1, 2);
						}
					} else if (k == 6) {
						walkableValue[j1][k1] |= 1;
						if (k1 > 0) {
							ao(j1, k1 - 1, 4);
						}
					}
				}

			}

			in(arg0, arg1, l, i1);
		}
	}

	public void updateObject(int arg0, int arg1, int arg2) {
		if (arg0 < 0 || arg1 < 0 || arg0 >= peb - 1 || arg1 >= qeb - 1) {
			return;
		}
		if (Cache.iib[arg2] == 1 || Cache.iib[arg2] == 2) {
			int k = dn(arg0, arg1);
			int l;
			int i1;
			if (k == 0 || k == 4) {
				l = Cache.gib[arg2];
				i1 = Cache.hib[arg2];
			} else {
				i1 = Cache.gib[arg2];
				l = Cache.hib[arg2];
			}
			for (int j1 = arg0; j1 < arg0 + l; j1++) {
				for (int k1 = arg1; k1 < arg1 + i1; k1++) {
					if (Cache.iib[arg2] == 1) {
						walkableValue[j1][k1] &= 0xffbf;
					} else if (k == 0) {
						walkableValue[j1][k1] &= 0xfffd;
						if (j1 > 0) {
							addMinusWalkable(j1 - 1, k1, 8);
						}
					} else if (k == 2) {
						walkableValue[j1][k1] &= 0xfffb;
						if (k1 < qeb - 1) {
							addMinusWalkable(j1, k1 + 1, 1);
						}
					} else if (k == 4) {
						walkableValue[j1][k1] &= 0xfff7;
						if (j1 < peb - 1) {
							addMinusWalkable(j1 + 1, k1, 2);
						}
					} else if (k == 6) {
						walkableValue[j1][k1] &= 0xfffe;
						if (k1 > 0) {
							addMinusWalkable(j1, k1 - 1, 4);
						}
					}
				}

			}

			in(arg0, arg1, l, i1);
		}
	}

	public void in(int arg0, int arg1, int arg2, int arg3) {
		if (arg0 < 1 || arg1 < 1 || arg0 + arg2 >= peb || arg1 + arg3 >= qeb) {
			return;
		}
		for (int k = arg0; k <= arg0 + arg2; k++) {
			for (int l = arg1; l <= arg1 + arg3; l++) {
				if ((fo(k, l) & 0x63) != 0 || (fo(k - 1, l) & 0x59) != 0
						|| (fo(k, l - 1) & 0x56) != 0
						|| (fo(k - 1, l - 1) & 0x6c) != 0) {
					nn(k, l, 35);
				} else {
					nn(k, l, 0);
				}
			}

		}

	}

	public void nn(int arg0, int arg1, int arg2) {
		int k = arg0 / 12;
		int l = arg1 / 12;
		int i1 = (arg0 - 1) / 12;
		int j1 = (arg1 - 1) / 12;
		co(k, l, arg0, arg1, arg2);
		if (k != i1) {
			co(i1, l, arg0, arg1, arg2);
		}
		if (l != j1) {
			co(k, j1, arg0, arg1, arg2);
		}
		if (k != i1 && l != j1) {
			co(i1, j1, arg0, arg1, arg2);
		}
	}

	public void co(int arg0, int arg1, int arg2, int arg3, int arg4) {
		Model h1 = xeb[arg0 + arg1 * 8];
		for (int k = 0; k < h1.jg; k++) {
			if (h1.ei[k] == arg2 * 128 && h1.gi[k] == arg3 * 128) {
				h1.ud(k, arg4);
				return;
			}
		}

	}

	public int fo(int arg0, int arg1) {
		if (arg0 < 0 || arg1 < 0 || arg0 >= peb || arg1 >= qeb) {
			return 0;
		} else {
			return walkableValue[arg0][arg1];
		}
	}

	public int getAveragedElevation(int arg0, int arg1) {
		int k = arg0 >> 7;
		int l = arg1 >> 7;
		int i1 = arg0 & 0x7f;
		int j1 = arg1 & 0x7f;
		if (k < 0 || l < 0 || k >= peb - 1 || l >= qeb - 1) {
			return 0;
		}
		int k1;
		int l1;
		int i2;
		if (i1 <= 128 - j1) {
			k1 = getGroundElevation(k, l);
			l1 = getGroundElevation(k + 1, l) - k1;
			i2 = getGroundElevation(k, l + 1) - k1;
		} else {
			k1 = getGroundElevation(k + 1, l + 1);
			l1 = getGroundElevation(k, l + 1) - k1;
			i2 = getGroundElevation(k + 1, l) - k1;
			i1 = 128 - i1;
			j1 = 128 - j1;
		}
		int j2 = k1 + (l1 * i1) / 128 + (i2 * j1) / 128;
		return j2;
	}

	public int getGroundElevation(int i, int j) {
		if (i < 0 || i >= 96 || j < 0 || j >= 96) {
			return 0;
		}
		byte byte0 = 0;
		if (i >= 48 && j < 48) {
			byte0 = 1;
			i -= 48;
		} else if (i < 48 && j >= 48) {
			byte0 = 2;
			j -= 48;
		} else if (i >= 48 && j >= 48) {
			byte0 = 3;
			i -= 48;
			j -= 48;
		}
		return (heb[byte0][i * 48 + j] & 0xff) * 3;
	}

	public int getGroundTexture(int arg0, int arg1) {
		if (arg0 < 0 || arg0 >= 96 || arg1 < 0 || arg1 >= 96) {
			return 0;
		}
		byte byte0 = 0;
		if (arg0 >= 48 && arg1 < 48) {
			byte0 = 1;
			arg0 -= 48;
		} else if (arg0 < 48 && arg1 >= 48) {
			byte0 = 2;
			arg1 -= 48;
		} else if (arg0 >= 48 && arg1 >= 48) {
			byte0 = 3;
			arg0 -= 48;
			arg1 -= 48;
		}
		return ieb[byte0][arg0 * 48 + arg1] & 0xff;
	}

	public int getGroundTexturesOverlay(int arg0, int arg1, int arg2) {
		if (arg0 < 0 || arg0 >= 96 || arg1 < 0 || arg1 >= 96) {
			return 0;
		}
		byte byte0 = 0;
		if (arg0 >= 48 && arg1 < 48) {
			byte0 = 1;
			arg0 -= 48;
		} else if (arg0 < 48 && arg1 >= 48) {
			byte0 = 2;
			arg1 -= 48;
		} else if (arg0 >= 48 && arg1 >= 48) {
			byte0 = 3;
			arg0 -= 48;
			arg1 -= 48;
		}
		return meb[byte0][arg0 * 48 + arg1] & 0xff;
	}

	public void mn(int arg0, int arg1, int arg2) {
		if (arg0 < 0 || arg0 >= 96 || arg1 < 0 || arg1 >= 96) {
			return;
		}
		byte byte0 = 0;
		if (arg0 >= 48 && arg1 < 48) {
			byte0 = 1;
			arg0 -= 48;
		} else if (arg0 < 48 && arg1 >= 48) {
			byte0 = 2;
			arg1 -= 48;
		} else if (arg0 >= 48 && arg1 >= 48) {
			byte0 = 3;
			arg0 -= 48;
			arg1 -= 48;
		}
		meb[byte0][arg0 * 48 + arg1] = (byte) arg2;
	}

	public int wn(int arg0, int arg1, int arg2) {
		int k = getGroundTexturesOverlay(arg0, arg1, arg2);
		if (k == 0) {
			return -1;
		}
		int l = Cache.ejb[k - 1];
		return l != 2 ? 0 : 1;
	}

	public int getOverlayIfRequired(int arg0, int arg1, int arg2, int arg3) {
		int k = getGroundTexturesOverlay(arg0, arg1, arg2);
		if (k == 0) {
			return arg3;
		} else {
			return Cache.djb[k - 1];
		}
	}

	public int getDiagonalWalls(int arg0, int arg1) {
		if (arg0 < 0 || arg0 >= 96 || arg1 < 0 || arg1 >= 96) {
			return 0;
		}
		byte byte0 = 0;
		if (arg0 >= 48 && arg1 < 48) {
			byte0 = 1;
			arg0 -= 48;
		} else if (arg0 < 48 && arg1 >= 48) {
			byte0 = 2;
			arg1 -= 48;
		} else if (arg0 >= 48 && arg1 >= 48) {
			byte0 = 3;
			arg0 -= 48;
			arg1 -= 48;
		}
		return oeb[byte0][arg0 * 48 + arg1];
	}

	public int vn(int arg0, int arg1) {
		if (arg0 < 0 || arg0 >= 96 || arg1 < 0 || arg1 >= 96) {
			return 0;
		}
		byte byte0 = 0;
		if (arg0 >= 48 && arg1 < 48) {
			byte0 = 1;
			arg0 -= 48;
		} else if (arg0 < 48 && arg1 >= 48) {
			byte0 = 2;
			arg1 -= 48;
		} else if (arg0 >= 48 && arg1 >= 48) {
			byte0 = 3;
			arg0 -= 48;
			arg1 -= 48;
		}
		return leb[byte0][arg0 * 48 + arg1];
	}

	public int dn(int arg0, int arg1) {
		if (arg0 < 0 || arg0 >= 96 || arg1 < 0 || arg1 >= 96) {
			return 0;
		}
		byte byte0 = 0;
		if (arg0 >= 48 && arg1 < 48) {
			byte0 = 1;
			arg0 -= 48;
		} else if (arg0 < 48 && arg1 >= 48) {
			byte0 = 2;
			arg1 -= 48;
		} else if (arg0 >= 48 && arg1 >= 48) {
			byte0 = 3;
			arg0 -= 48;
			arg1 -= 48;
		}
		return neb[byte0][arg0 * 48 + arg1];
	}

	public boolean yn(int arg0, int arg1) {
		return vn(arg0, arg1) > 0 || vn(arg0 - 1, arg1) > 0
				|| vn(arg0 - 1, arg1 - 1) > 0 || vn(arg0, arg1 - 1) > 0;
	}

	public boolean xn(int arg0, int arg1) {
		return vn(arg0, arg1) > 0 && vn(arg0 - 1, arg1) > 0
				&& vn(arg0 - 1, arg1 - 1) > 0 && vn(arg0, arg1 - 1) > 0;
	}

	public int kn(int arg0, int arg1) {
		if (arg0 < 0 || arg0 >= 96 || arg1 < 0 || arg1 >= 96) {
			return 0;
		}
		byte byte0 = 0;
		if (arg0 >= 48 && arg1 < 48) {
			byte0 = 1;
			arg0 -= 48;
		} else if (arg0 < 48 && arg1 >= 48) {
			byte0 = 2;
			arg1 -= 48;
		} else if (arg0 >= 48 && arg1 >= 48) {
			byte0 = 3;
			arg0 -= 48;
			arg1 -= 48;
		}
		return keb[byte0][arg0 * 48 + arg1] & 0xff;
	}

	public int sn(int arg0, int arg1) {
		if (arg0 < 0 || arg0 >= 96 || arg1 < 0 || arg1 >= 96) {
			return 0;
		}
		byte byte0 = 0;
		if (arg0 >= 48 && arg1 < 48) {
			byte0 = 1;
			arg0 -= 48;
		} else if (arg0 < 48 && arg1 >= 48) {
			byte0 = 2;
			arg1 -= 48;
		} else if (arg0 >= 48 && arg1 >= 48) {
			byte0 = 3;
			arg0 -= 48;
			arg1 -= 48;
		}
		return jeb[byte0][arg0 * 48 + arg1] & 0xff;
	}

	public void loadSection(int arg0, int arg1, int arg2, int arg3) {
		String s = "m" + arg2 + arg0 / 10 + arg0 % 10 + arg1 / 10 + arg1 % 10;
		int k;
		try {
			byte abyte0[];
			if (udb) {
				abyte0 = DataOperations.lm(s + ".jm", 0, geb);
				if (abyte0 == null || abyte0.length == 0) {
					throw new IOException("Map not defined");
				}
			} else {
				abyte0 = new byte[20736];
				DataOperations.readFromPath("../gamedata/maps/" + s + ".jm",
						abyte0, 20736);
			}
			int l = 0;
			int i1 = 0;
			for (int j1 = 0; j1 < 2304; j1++) {
				l = l + abyte0[i1++] & 0xff;
				heb[arg3][j1] = (byte) l;
			}

			l = 0;
			for (int k1 = 0; k1 < 2304; k1++) {
				l = l + abyte0[i1++] & 0xff;
				ieb[arg3][k1] = (byte) l;
			}

			for (int l1 = 0; l1 < 2304; l1++) {
				jeb[arg3][l1] = abyte0[i1++];
			}

			for (int i2 = 0; i2 < 2304; i2++) {
				keb[arg3][i2] = abyte0[i1++];
			}

			for (int j2 = 0; j2 < 2304; j2++) {
				oeb[arg3][j2] = (abyte0[i1] & 0xff) * 256
						+ (abyte0[i1 + 1] & 0xff);
				i1 += 2;
			}

			for (int k2 = 0; k2 < 2304; k2++) {
				leb[arg3][k2] = abyte0[i1++];
			}

			for (int l2 = 0; l2 < 2304; l2++) {
				meb[arg3][l2] = abyte0[i1++];
			}

			for (int i3 = 0; i3 < 2304; i3++) {
				neb[arg3][i3] = abyte0[i1++];
			}

			return;
		} catch (IOException _ex) {
			k = 0;
		}
		for (; k < 2304; k++) {
			heb[arg3][k] = 0;
			ieb[arg3][k] = 0;
			jeb[arg3][k] = 0;
			keb[arg3][k] = 0;
			oeb[arg3][k] = 0;
			leb[arg3][k] = 0;
			meb[arg3][k] = 0;
			if (arg2 == 0) {
				meb[arg3][k] = -6;
			}
			if (arg2 == 3) {
				meb[arg3][k] = 8;
			}
			neb[arg3][k] = 0;
		}

	}

	public void eo() {
		xdb.cleanupModels();
		for (int k = 0; k < 64; k++) {
			xeb[k] = null;
			for (int l = 0; l < 4; l++) {
				yeb[l][k] = null;
			}

			for (int i1 = 0; i1 < 4; i1++) {
				zeb[i1][k] = null;
			}

		}

		System.gc();
	}

	public void rn(int arg0, int arg1, int arg2) {
		eo();
		int k = (arg0 + 24) / 48;
		int l = (arg1 + 24) / 48;
		fn(arg0, arg1, arg2, true);
		if (arg2 == 0) {
			fn(arg0, arg1, 1, false);
			fn(arg0, arg1, 2, false);
			loadSection(k - 1, l - 1, arg2, 0);
			loadSection(k, l - 1, arg2, 1);
			loadSection(k - 1, l, arg2, 2);
			loadSection(k, l, arg2, 3);
			ln();
		}
	}

	public void ln() {
		for (int k = 0; k < 96; k++) {
			for (int l = 0; l < 96; l++) {
				if (getGroundTexturesOverlay(k, l, 0) == 250) {
					if (k == 47 && getGroundTexturesOverlay(k + 1, l, 0) != 250
							&& getGroundTexturesOverlay(k + 1, l, 0) != 2) {
						mn(k, l, 9);
					} else if (l == 47
							&& getGroundTexturesOverlay(k, l + 1, 0) != 250
							&& getGroundTexturesOverlay(k, l + 1, 0) != 2) {
						mn(k, l, 9);
					} else {
						mn(k, l, 2);
					}
				}
			}

		}

	}

	public void en(int arg0, int arg1, int arg2, int arg3, int arg4) {
		int k = arg0 * 3;
		int l = arg1 * 3;
		int i1 = xdb.oi(arg3);
		int j1 = xdb.oi(arg4);
		i1 = i1 >> 1 & 0x7f7f7f;
		j1 = j1 >> 1 & 0x7f7f7f;
		if (arg2 == 0) {
			gameImage.drawLineX(k, l, 3, i1);
			gameImage.drawLineX(k, l + 1, 2, i1);
			gameImage.drawLineX(k, l + 2, 1, i1);
			gameImage.drawLineX(k + 2, l + 1, 1, j1);
			gameImage.drawLineX(k + 1, l + 2, 2, j1);
			return;
		}
		if (arg2 == 1) {
			gameImage.drawLineX(k, l, 3, j1);
			gameImage.drawLineX(k + 1, l + 1, 2, j1);
			gameImage.drawLineX(k + 2, l + 2, 1, j1);
			gameImage.drawLineX(k, l + 1, 1, i1);
			gameImage.drawLineX(k, l + 2, 2, i1);
		}
	}

	public void fn(int arg0, int arg1, int arg2, boolean arg3) {
		int k = (arg0 + 24) / 48;
		int l = (arg1 + 24) / 48;
		loadSection(k - 1, l - 1, arg2, 0);
		loadSection(k, l - 1, arg2, 1);
		loadSection(k - 1, l, arg2, 2);
		loadSection(k, l, arg2, 3);
		ln();
		if (afb == null) {
			afb = new Model(peb * qeb * 2 + 256, peb * qeb * 2 + 256, true,
					true, false, false, true);
		}
		if (arg3) {
			gameImage.df();
			for (int i1 = 0; i1 < 96; i1++) {
				for (int k1 = 0; k1 < 96; k1++) {
					walkableValue[i1][k1] = 0;
				}

			}

			Model h1 = afb;
			h1.re();
			for (int i2 = 0; i2 < 96; i2++) {
				for (int l2 = 0; l2 < 96; l2++) {
					int l3 = -getGroundElevation(i2, l2);
					if (getGroundTexturesOverlay(i2, l2, arg2) > 0
							&& Cache.ejb[getGroundTexturesOverlay(i2, l2, arg2) - 1] == 4) {
						l3 = 0;
					}
					if (getGroundTexturesOverlay(i2 - 1, l2, arg2) > 0
							&& Cache.ejb[getGroundTexturesOverlay(i2 - 1, l2,
									arg2) - 1] == 4) {
						l3 = 0;
					}
					if (getGroundTexturesOverlay(i2, l2 - 1, arg2) > 0
							&& Cache.ejb[getGroundTexturesOverlay(i2, l2 - 1,
									arg2) - 1] == 4) {
						l3 = 0;
					}
					if (getGroundTexturesOverlay(i2 - 1, l2 - 1, arg2) > 0
							&& Cache.ejb[getGroundTexturesOverlay(i2 - 1,
									l2 - 1, arg2) - 1] == 4) {
						l3 = 0;
					}
					int i5 = h1.je(i2 * 128, l3, l2 * 128);
					int i7 = (int) (Math.random() * 10D) - 5;
					h1.ud(i5, i7);
				}

			}

			for (int i3 = 0; i3 < 95; i3++) {
				for (int i4 = 0; i4 < 95; i4++) {
					int j5 = getGroundTexture(i3, i4);
					int j7 = groundTextureArray[j5];
					int l9 = j7;
					int j12 = j7;
					int k14 = 0;
					if (arg2 == 1 || arg2 == 2) {
						j7 = 0xbc614e;
						l9 = 0xbc614e;
						j12 = 0xbc614e;
					}
					if (getGroundTexturesOverlay(i3, i4, arg2) > 0) {
						int k16 = getGroundTexturesOverlay(i3, i4, arg2);
						int k5 = Cache.ejb[k16 - 1];
						int l18 = wn(i3, i4, arg2);
						j7 = l9 = Cache.djb[k16 - 1];
						if (k5 == 4) {
							j7 = 1;
							l9 = 1;
						}
						if (k5 == 5) {
							if (getDiagonalWalls(i3, i4) > 0
									&& getDiagonalWalls(i3, i4) < 24000) {
								if (getOverlayIfRequired(i3 - 1, i4, arg2, j12) != 0xbc614e
										&& getOverlayIfRequired(i3, i4 - 1,
												arg2, j12) != 0xbc614e) {
									j7 = getOverlayIfRequired(i3 - 1, i4, arg2,
											j12);
									k14 = 0;
								} else if (getOverlayIfRequired(i3 + 1, i4,
										arg2, j12) != 0xbc614e
										&& getOverlayIfRequired(i3, i4 + 1,
												arg2, j12) != 0xbc614e) {
									l9 = getOverlayIfRequired(i3 + 1, i4, arg2,
											j12);
									k14 = 0;
								} else if (getOverlayIfRequired(i3 + 1, i4,
										arg2, j12) != 0xbc614e
										&& getOverlayIfRequired(i3, i4 - 1,
												arg2, j12) != 0xbc614e) {
									l9 = getOverlayIfRequired(i3 + 1, i4, arg2,
											j12);
									k14 = 1;
								} else if (getOverlayIfRequired(i3 - 1, i4,
										arg2, j12) != 0xbc614e
										&& getOverlayIfRequired(i3, i4 + 1,
												arg2, j12) != 0xbc614e) {
									j7 = getOverlayIfRequired(i3 - 1, i4, arg2,
											j12);
									k14 = 1;
								}
							}
						} else if (k5 != 2 || getDiagonalWalls(i3, i4) > 0
								&& getDiagonalWalls(i3, i4) < 24000) {
							if (wn(i3 - 1, i4, arg2) != l18
									&& wn(i3, i4 - 1, arg2) != l18) {
								j7 = j12;
								k14 = 0;
							} else if (wn(i3 + 1, i4, arg2) != l18
									&& wn(i3, i4 + 1, arg2) != l18) {
								l9 = j12;
								k14 = 0;
							} else if (wn(i3 + 1, i4, arg2) != l18
									&& wn(i3, i4 - 1, arg2) != l18) {
								l9 = j12;
								k14 = 1;
							} else if (wn(i3 - 1, i4, arg2) != l18
									&& wn(i3, i4 + 1, arg2) != l18) {
								j7 = j12;
								k14 = 1;
							}
						}
						if (Cache.fjb[k16 - 1] != 0) {
							walkableValue[i3][i4] |= 0x40;
						}
						if (Cache.ejb[k16 - 1] == 2) {
							walkableValue[i3][i4] |= 0x80;
						}
					}
					en(i3, i4, k14, j7, l9);
					int l16 = ((getGroundElevation(i3 + 1, i4 + 1) - getGroundElevation(
							i3 + 1, i4)) + getGroundElevation(i3, i4 + 1))
							- getGroundElevation(i3, i4);
					if (j7 != l9 || l16 != 0) {
						int ai[] = new int[3];
						int ai7[] = new int[3];
						if (k14 == 0) {
							if (j7 != 0xbc614e) {
								ai[0] = i4 + i3 * peb + peb;
								ai[1] = i4 + i3 * peb;
								ai[2] = i4 + i3 * peb + 1;
								int k21 = h1.ie(3, ai, 0xbc614e, j7);
								reb[k21] = i3;
								seb[k21] = i4;
								h1.qh[k21] = 0x30d40 + k21;
							}
							if (l9 != 0xbc614e) {
								ai7[0] = i4 + i3 * peb + 1;
								ai7[1] = i4 + i3 * peb + peb + 1;
								ai7[2] = i4 + i3 * peb + peb;
								int l21 = h1.ie(3, ai7, 0xbc614e, l9);
								reb[l21] = i3;
								seb[l21] = i4;
								h1.qh[l21] = 0x30d40 + l21;
							}
						} else {
							if (j7 != 0xbc614e) {
								ai[0] = i4 + i3 * peb + 1;
								ai[1] = i4 + i3 * peb + peb + 1;
								ai[2] = i4 + i3 * peb;
								int i22 = h1.ie(3, ai, 0xbc614e, j7);
								reb[i22] = i3;
								seb[i22] = i4;
								h1.qh[i22] = 0x30d40 + i22;
							}
							if (l9 != 0xbc614e) {
								ai7[0] = i4 + i3 * peb + peb;
								ai7[1] = i4 + i3 * peb;
								ai7[2] = i4 + i3 * peb + peb + 1;
								int j22 = h1.ie(3, ai7, 0xbc614e, l9);
								reb[j22] = i3;
								seb[j22] = i4;
								h1.qh[j22] = 0x30d40 + j22;
							}
						}
					} else if (j7 != 0xbc614e) {
						int ai1[] = new int[4];
						ai1[0] = i4 + i3 * peb + peb;
						ai1[1] = i4 + i3 * peb;
						ai1[2] = i4 + i3 * peb + 1;
						ai1[3] = i4 + i3 * peb + peb + 1;
						int k19 = h1.ie(4, ai1, 0xbc614e, j7);
						reb[k19] = i3;
						seb[k19] = i4;
						h1.qh[k19] = 0x30d40 + k19;
					}
				}

			}

			for (int j4 = 1; j4 < 95; j4++) {
				for (int l5 = 1; l5 < 95; l5++) {
					if (getGroundTexturesOverlay(j4, l5, arg2) > 0
							&& Cache.ejb[getGroundTexturesOverlay(j4, l5, arg2) - 1] == 4) {
						int k7 = Cache.djb[getGroundTexturesOverlay(j4, l5,
								arg2) - 1];
						int i10 = h1.je(j4 * 128, -getGroundElevation(j4, l5),
								l5 * 128);
						int k12 = h1.je((j4 + 1) * 128,
								-getGroundElevation(j4 + 1, l5), l5 * 128);
						int l14 = h1.je((j4 + 1) * 128,
								-getGroundElevation(j4 + 1, l5 + 1),
								(l5 + 1) * 128);
						int i17 = h1
								.je(j4 * 128, -getGroundElevation(j4, l5 + 1),
										(l5 + 1) * 128);
						int ai2[] = { i10, k12, l14, i17 };
						int l19 = h1.ie(4, ai2, k7, 0xbc614e);
						reb[l19] = j4;
						seb[l19] = l5;
						h1.qh[l19] = 0x30d40 + l19;
						en(j4, l5, 0, k7, k7);
					} else if (getGroundTexturesOverlay(j4, l5, arg2) == 0
							|| Cache.ejb[getGroundTexturesOverlay(j4, l5, arg2) - 1] != 3) {
						if (getGroundTexturesOverlay(j4, l5 + 1, arg2) > 0
								&& Cache.ejb[getGroundTexturesOverlay(j4,
										l5 + 1, arg2) - 1] == 4) {
							int l7 = Cache.djb[getGroundTexturesOverlay(j4,
									l5 + 1, arg2) - 1];
							int j10 = h1.je(j4 * 128,
									-getGroundElevation(j4, l5), l5 * 128);
							int l12 = h1.je((j4 + 1) * 128,
									-getGroundElevation(j4 + 1, l5), l5 * 128);
							int i15 = h1.je((j4 + 1) * 128,
									-getGroundElevation(j4 + 1, l5 + 1),
									(l5 + 1) * 128);
							int j17 = h1.je(j4 * 128,
									-getGroundElevation(j4, l5 + 1),
									(l5 + 1) * 128);
							int ai3[] = { j10, l12, i15, j17 };
							int i20 = h1.ie(4, ai3, l7, 0xbc614e);
							reb[i20] = j4;
							seb[i20] = l5;
							h1.qh[i20] = 0x30d40 + i20;
							en(j4, l5, 0, l7, l7);
						}
						if (getGroundTexturesOverlay(j4, l5 - 1, arg2) > 0
								&& Cache.ejb[getGroundTexturesOverlay(j4,
										l5 - 1, arg2) - 1] == 4) {
							int i8 = Cache.djb[getGroundTexturesOverlay(j4,
									l5 - 1, arg2) - 1];
							int k10 = h1.je(j4 * 128,
									-getGroundElevation(j4, l5), l5 * 128);
							int i13 = h1.je((j4 + 1) * 128,
									-getGroundElevation(j4 + 1, l5), l5 * 128);
							int j15 = h1.je((j4 + 1) * 128,
									-getGroundElevation(j4 + 1, l5 + 1),
									(l5 + 1) * 128);
							int k17 = h1.je(j4 * 128,
									-getGroundElevation(j4, l5 + 1),
									(l5 + 1) * 128);
							int ai4[] = { k10, i13, j15, k17 };
							int j20 = h1.ie(4, ai4, i8, 0xbc614e);
							reb[j20] = j4;
							seb[j20] = l5;
							h1.qh[j20] = 0x30d40 + j20;
							en(j4, l5, 0, i8, i8);
						}
						if (getGroundTexturesOverlay(j4 + 1, l5, arg2) > 0
								&& Cache.ejb[getGroundTexturesOverlay(j4 + 1,
										l5, arg2) - 1] == 4) {
							int j8 = Cache.djb[getGroundTexturesOverlay(j4 + 1,
									l5, arg2) - 1];
							int l10 = h1.je(j4 * 128,
									-getGroundElevation(j4, l5), l5 * 128);
							int j13 = h1.je((j4 + 1) * 128,
									-getGroundElevation(j4 + 1, l5), l5 * 128);
							int k15 = h1.je((j4 + 1) * 128,
									-getGroundElevation(j4 + 1, l5 + 1),
									(l5 + 1) * 128);
							int l17 = h1.je(j4 * 128,
									-getGroundElevation(j4, l5 + 1),
									(l5 + 1) * 128);
							int ai5[] = { l10, j13, k15, l17 };
							int k20 = h1.ie(4, ai5, j8, 0xbc614e);
							reb[k20] = j4;
							seb[k20] = l5;
							h1.qh[k20] = 0x30d40 + k20;
							en(j4, l5, 0, j8, j8);
						}
						if (getGroundTexturesOverlay(j4 - 1, l5, arg2) > 0
								&& Cache.ejb[getGroundTexturesOverlay(j4 - 1,
										l5, arg2) - 1] == 4) {
							int k8 = Cache.djb[getGroundTexturesOverlay(j4 - 1,
									l5, arg2) - 1];
							int i11 = h1.je(j4 * 128,
									-getGroundElevation(j4, l5), l5 * 128);
							int k13 = h1.je((j4 + 1) * 128,
									-getGroundElevation(j4 + 1, l5), l5 * 128);
							int l15 = h1.je((j4 + 1) * 128,
									-getGroundElevation(j4 + 1, l5 + 1),
									(l5 + 1) * 128);
							int i18 = h1.je(j4 * 128,
									-getGroundElevation(j4, l5 + 1),
									(l5 + 1) * 128);
							int ai6[] = { i11, k13, l15, i18 };
							int l20 = h1.ie(4, ai6, k8, 0xbc614e);
							reb[l20] = j4;
							seb[l20] = l5;
							h1.qh[l20] = 0x30d40 + l20;
							en(j4, l5, 0, k8, k8);
						}
					}
				}

			}

			h1.ne(true, 40, 48, -50, -10, -50);
			xeb = afb.rd(0, 0, 1536, 1536, 8, 64, 233, false);
			for (int i6 = 0; i6 < 64; i6++) {
				xdb.addModel(xeb[i6]);
			}

			for (int l8 = 0; l8 < 96; l8++) {
				for (int j11 = 0; j11 < 96; j11++) {
					veb[l8][j11] = getGroundElevation(l8, j11);
				}

			}

		}
		afb.re();
		int j1 = 0x606060;
		for (int l1 = 0; l1 < 95; l1++) {
			for (int j2 = 0; j2 < 95; j2++) {
				int j3 = kn(l1, j2);
				if (j3 > 0 && (Cache.vib[j3 - 1] == 0 || vdb)) {
					_mthdo(afb, j3 - 1, l1, j2, l1 + 1, j2);
					if (arg3 && Cache.tib[j3 - 1] != 0) {
						walkableValue[l1][j2] |= 1;
						if (j2 > 0) {
							ao(l1, j2 - 1, 4);
						}
					}
					if (arg3) {
						gameImage.drawLineX(l1 * 3, j2 * 3, 3, j1);
					}
				}
				j3 = sn(l1, j2);
				if (j3 > 0 && (Cache.vib[j3 - 1] == 0 || vdb)) {
					_mthdo(afb, j3 - 1, l1, j2, l1, j2 + 1);
					if (arg3 && Cache.tib[j3 - 1] != 0) {
						walkableValue[l1][j2] |= 2;
						if (l1 > 0) {
							ao(l1 - 1, j2, 8);
						}
					}
					if (arg3) {
						gameImage.drawLineY(l1 * 3, j2 * 3, 3, j1);
					}
				}
				j3 = getDiagonalWalls(l1, j2);
				if (j3 > 0 && j3 < 12000 && (Cache.vib[j3 - 1] == 0 || vdb)) {
					_mthdo(afb, j3 - 1, l1, j2, l1 + 1, j2 + 1);
					if (arg3 && Cache.tib[j3 - 1] != 0) {
						walkableValue[l1][j2] |= 0x20;
					}
					if (arg3) {
						gameImage.setPixelColour(l1 * 3, j2 * 3, j1);
						gameImage.setPixelColour(l1 * 3 + 1, j2 * 3 + 1, j1);
						gameImage.setPixelColour(l1 * 3 + 2, j2 * 3 + 2, j1);
					}
				}
				if (j3 > 12000 && j3 < 24000
						&& (Cache.vib[j3 - 12001] == 0 || vdb)) {
					_mthdo(afb, j3 - 12001, l1 + 1, j2, l1, j2 + 1);
					if (arg3 && Cache.tib[j3 - 12001] != 0) {
						walkableValue[l1][j2] |= 0x10;
					}
					if (arg3) {
						gameImage.setPixelColour(l1 * 3 + 2, j2 * 3, j1);
						gameImage.setPixelColour(l1 * 3 + 1, j2 * 3 + 1, j1);
						gameImage.setPixelColour(l1 * 3, j2 * 3 + 2, j1);
					}
				}
			}

		}

		if (arg3) {
			gameImage.jf(ydb - 1, 0, 0, 285, 285);
		}
		afb.ne(false, 60, 24, -50, -10, -50);
		yeb[arg2] = afb.rd(0, 0, 1536, 1536, 8, 64, 338, true);
		for (int k2 = 0; k2 < 64; k2++) {
			xdb.addModel(yeb[arg2][k2]);
		}

		for (int k3 = 0; k3 < 95; k3++) {
			for (int k4 = 0; k4 < 95; k4++) {
				int j6 = kn(k3, k4);
				if (j6 > 0) {
					un(j6 - 1, k3, k4, k3 + 1, k4);
				}
				j6 = sn(k3, k4);
				if (j6 > 0) {
					un(j6 - 1, k3, k4, k3, k4 + 1);
				}
				j6 = getDiagonalWalls(k3, k4);
				if (j6 > 0 && j6 < 12000) {
					un(j6 - 1, k3, k4, k3 + 1, k4 + 1);
				}
				if (j6 > 12000 && j6 < 24000) {
					un(j6 - 12001, k3 + 1, k4, k3, k4 + 1);
				}
			}

		}

		for (int l4 = 1; l4 < 95; l4++) {
			for (int k6 = 1; k6 < 95; k6++) {
				int i9 = vn(l4, k6);
				if (i9 > 0) {
					int k11 = l4;
					int l13 = k6;
					int i16 = l4 + 1;
					int j18 = k6;
					int i19 = l4 + 1;
					int i21 = k6 + 1;
					int k22 = l4;
					int i23 = k6 + 1;
					int k23 = 0;
					int i24 = veb[k11][l13];
					int k24 = veb[i16][j18];
					int i25 = veb[i19][i21];
					int k25 = veb[k22][i23];
					if (i24 > 0x13880) {
						i24 -= 0x13880;
					}
					if (k24 > 0x13880) {
						k24 -= 0x13880;
					}
					if (i25 > 0x13880) {
						i25 -= 0x13880;
					}
					if (k25 > 0x13880) {
						k25 -= 0x13880;
					}
					if (i24 > k23) {
						k23 = i24;
					}
					if (k24 > k23) {
						k23 = k24;
					}
					if (i25 > k23) {
						k23 = i25;
					}
					if (k25 > k23) {
						k23 = k25;
					}
					if (k23 >= 0x13880) {
						k23 -= 0x13880;
					}
					if (i24 < 0x13880) {
						veb[k11][l13] = k23;
					} else {
						veb[k11][l13] -= 0x13880;
					}
					if (k24 < 0x13880) {
						veb[i16][j18] = k23;
					} else {
						veb[i16][j18] -= 0x13880;
					}
					if (i25 < 0x13880) {
						veb[i19][i21] = k23;
					} else {
						veb[i19][i21] -= 0x13880;
					}
					if (k25 < 0x13880) {
						veb[k22][i23] = k23;
					} else {
						veb[k22][i23] -= 0x13880;
					}
				}
			}

		}

		afb.re();
		for (int l6 = 1; l6 < 95; l6++) {
			for (int j9 = 1; j9 < 95; j9++) {
				int l11 = vn(l6, j9);
				if (l11 > 0) {
					int i14 = l6;
					int j16 = j9;
					int k18 = l6 + 1;
					int j19 = j9;
					int j21 = l6 + 1;
					int l22 = j9 + 1;
					int j23 = l6;
					int l23 = j9 + 1;
					int j24 = l6 * 128;
					int l24 = j9 * 128;
					int j25 = j24 + 128;
					int l25 = l24 + 128;
					int i26 = j24;
					int j26 = l24;
					int k26 = j25;
					int l26 = l25;
					int i27 = veb[i14][j16];
					int j27 = veb[k18][j19];
					int k27 = veb[j21][l22];
					int l27 = veb[j23][l23];
					int i28 = Cache.yib[l11 - 1];
					if (xn(i14, j16) && i27 < 0x13880) {
						i27 += i28 + 0x13880;
						veb[i14][j16] = i27;
					}
					if (xn(k18, j19) && j27 < 0x13880) {
						j27 += i28 + 0x13880;
						veb[k18][j19] = j27;
					}
					if (xn(j21, l22) && k27 < 0x13880) {
						k27 += i28 + 0x13880;
						veb[j21][l22] = k27;
					}
					if (xn(j23, l23) && l27 < 0x13880) {
						l27 += i28 + 0x13880;
						veb[j23][l23] = l27;
					}
					if (i27 >= 0x13880) {
						i27 -= 0x13880;
					}
					if (j27 >= 0x13880) {
						j27 -= 0x13880;
					}
					if (k27 >= 0x13880) {
						k27 -= 0x13880;
					}
					if (l27 >= 0x13880) {
						l27 -= 0x13880;
					}
					byte byte0 = 16;
					if (!yn(i14 - 1, j16)) {
						j24 -= byte0;
					}
					if (!yn(i14 + 1, j16)) {
						j24 += byte0;
					}
					if (!yn(i14, j16 - 1)) {
						l24 -= byte0;
					}
					if (!yn(i14, j16 + 1)) {
						l24 += byte0;
					}
					if (!yn(k18 - 1, j19)) {
						j25 -= byte0;
					}
					if (!yn(k18 + 1, j19)) {
						j25 += byte0;
					}
					if (!yn(k18, j19 - 1)) {
						j26 -= byte0;
					}
					if (!yn(k18, j19 + 1)) {
						j26 += byte0;
					}
					if (!yn(j21 - 1, l22)) {
						k26 -= byte0;
					}
					if (!yn(j21 + 1, l22)) {
						k26 += byte0;
					}
					if (!yn(j21, l22 - 1)) {
						l25 -= byte0;
					}
					if (!yn(j21, l22 + 1)) {
						l25 += byte0;
					}
					if (!yn(j23 - 1, l23)) {
						i26 -= byte0;
					}
					if (!yn(j23 + 1, l23)) {
						i26 += byte0;
					}
					if (!yn(j23, l23 - 1)) {
						l26 -= byte0;
					}
					if (!yn(j23, l23 + 1)) {
						l26 += byte0;
					}
					l11 = Cache.ajb[l11 - 1];
					i27 = -i27;
					j27 = -j27;
					k27 = -k27;
					l27 = -l27;
					if (getDiagonalWalls(l6, j9) > 12000
							&& getDiagonalWalls(l6, j9) < 24000
							&& vn(l6 - 1, j9 - 1) == 0) {
						int ai8[] = new int[3];
						ai8[0] = afb.je(k26, k27, l25);
						ai8[1] = afb.je(i26, l27, l26);
						ai8[2] = afb.je(j25, j27, j26);
						afb.ie(3, ai8, l11, 0xbc614e);
					} else if (getDiagonalWalls(l6, j9) > 12000
							&& getDiagonalWalls(l6, j9) < 24000
							&& vn(l6 + 1, j9 + 1) == 0) {
						int ai9[] = new int[3];
						ai9[0] = afb.je(j24, i27, l24);
						ai9[1] = afb.je(j25, j27, j26);
						ai9[2] = afb.je(i26, l27, l26);
						afb.ie(3, ai9, l11, 0xbc614e);
					} else if (getDiagonalWalls(l6, j9) > 0
							&& getDiagonalWalls(l6, j9) < 12000
							&& vn(l6 + 1, j9 - 1) == 0) {
						int ai10[] = new int[3];
						ai10[0] = afb.je(i26, l27, l26);
						ai10[1] = afb.je(j24, i27, l24);
						ai10[2] = afb.je(k26, k27, l25);
						afb.ie(3, ai10, l11, 0xbc614e);
					} else if (getDiagonalWalls(l6, j9) > 0
							&& getDiagonalWalls(l6, j9) < 12000
							&& vn(l6 - 1, j9 + 1) == 0) {
						int ai11[] = new int[3];
						ai11[0] = afb.je(j25, j27, j26);
						ai11[1] = afb.je(k26, k27, l25);
						ai11[2] = afb.je(j24, i27, l24);
						afb.ie(3, ai11, l11, 0xbc614e);
					} else if (i27 == j27 && k27 == l27) {
						int ai12[] = new int[4];
						ai12[0] = afb.je(j24, i27, l24);
						ai12[1] = afb.je(j25, j27, j26);
						ai12[2] = afb.je(k26, k27, l25);
						ai12[3] = afb.je(i26, l27, l26);
						afb.ie(4, ai12, l11, 0xbc614e);
					} else if (i27 == l27 && j27 == k27) {
						int ai13[] = new int[4];
						ai13[0] = afb.je(i26, l27, l26);
						ai13[1] = afb.je(j24, i27, l24);
						ai13[2] = afb.je(j25, j27, j26);
						ai13[3] = afb.je(k26, k27, l25);
						afb.ie(4, ai13, l11, 0xbc614e);
					} else {
						boolean flag = true;
						if (vn(l6 - 1, j9 - 1) > 0) {
							flag = false;
						}
						if (vn(l6 + 1, j9 + 1) > 0) {
							flag = false;
						}
						if (!flag) {
							int ai14[] = new int[3];
							ai14[0] = afb.je(j25, j27, j26);
							ai14[1] = afb.je(k26, k27, l25);
							ai14[2] = afb.je(j24, i27, l24);
							afb.ie(3, ai14, l11, 0xbc614e);
							int ai16[] = new int[3];
							ai16[0] = afb.je(i26, l27, l26);
							ai16[1] = afb.je(j24, i27, l24);
							ai16[2] = afb.je(k26, k27, l25);
							afb.ie(3, ai16, l11, 0xbc614e);
						} else {
							int ai15[] = new int[3];
							ai15[0] = afb.je(j24, i27, l24);
							ai15[1] = afb.je(j25, j27, j26);
							ai15[2] = afb.je(i26, l27, l26);
							afb.ie(3, ai15, l11, 0xbc614e);
							int ai17[] = new int[3];
							ai17[0] = afb.je(k26, k27, l25);
							ai17[1] = afb.je(i26, l27, l26);
							ai17[2] = afb.je(j25, j27, j26);
							afb.ie(3, ai17, l11, 0xbc614e);
						}
					}
				}
			}

		}

		afb.ne(true, 50, 50, -50, -10, -50);
		zeb[arg2] = afb.rd(0, 0, 1536, 1536, 8, 64, 169, true);
		for (int k9 = 0; k9 < 64; k9++) {
			xdb.addModel(zeb[arg2][k9]);
		}

		for (int i12 = 0; i12 < 96; i12++) {
			for (int j14 = 0; j14 < 96; j14++) {
				if (veb[i12][j14] >= 0x13880) {
					veb[i12][j14] -= 0x13880;
				}
			}

		}

	}

	public void _mthdo(Model arg0, int arg1, int arg2, int arg3, int arg4,
			int arg5) {
		nn(arg2, arg3, 40);
		nn(arg4, arg5, 40);
		int k = Cache.qib[arg1];
		int l = Cache.rib[arg1];
		int i1 = Cache.sib[arg1];
		int j1 = arg2 * 128;
		int k1 = arg3 * 128;
		int l1 = arg4 * 128;
		int i2 = arg5 * 128;
		int j2 = arg0.je(j1, -veb[arg2][arg3], k1);
		int k2 = arg0.je(j1, -veb[arg2][arg3] - k, k1);
		int l2 = arg0.je(l1, -veb[arg4][arg5] - k, i2);
		int i3 = arg0.je(l1, -veb[arg4][arg5], i2);
		int ai[] = { j2, k2, l2, i3 };
		int j3 = arg0.ie(4, ai, l, i1);
		if (Cache.vib[arg1] == 5) {
			arg0.qh[j3] = 30000 + arg1;
			return;
		} else {
			arg0.qh[j3] = 0;
			return;
		}
	}

	public void un(int arg0, int arg1, int arg2, int arg3, int arg4) {
		int k = Cache.qib[arg0];
		if (veb[arg1][arg2] < 0x13880) {
			veb[arg1][arg2] += 0x13880 + k;
		}
		if (veb[arg3][arg4] < 0x13880) {
			veb[arg3][arg4] += 0x13880 + k;
		}
	}

	boolean udb;
	boolean vdb;
	GameImage gameImage;
	Camera xdb;
	int ydb;
	final int zdb = 0xbc614e;
	final int aeb = 128;
	int groundTextureArray[];
	int ceb;
	int deb[];
	int eeb[];
	int feb[];
	byte geb[];
	byte heb[][];
	byte ieb[][];
	byte jeb[][];
	byte keb[][];
	byte leb[][];
	byte meb[][];
	byte neb[][];
	int oeb[][];
	int peb;
	int qeb;
	int reb[];
	int seb[];
	int tmpTiles[][];
	int walkableValue[][];
	int veb[][];
	boolean playerIsAlive;
	Model xeb[];
	Model yeb[][];
	Model zeb[][];
	Model afb;
}
